package cn.lyjuan.dwz_manage.core.java.action;

import cn.lyjuan.dwz_manage.core.java.cst.DwzManageCst;
import cn.lyjuan.dwz_manage.core.java.exception.ErrorCode;
import cn.lyjuan.dwz_manage.core.java.util.ActionUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by chad on 2016/8/23.
 */
@Controller
@RequestMapping("login/")
public class LoginAction extends BaseAction
{
    private static Logger log = LogManager.getLogger(LoginAction.class.getName());

    @Autowired
    private DwzManageCst dwzManageCst;

    @RequestMapping("login")
    @ResponseBody
    public ModelAndView login(HttpServletRequest req)
    {
        log.info("into login");

        boolean isAjax =  ActionUtils.isAjaxRequest(req);

        if (isAjax)
        {
            this.returnDwzAjaxFail(ErrorCode.Mg.NO_LOGIN, "请登陆！");
            return null;
        }
        // 默认跟请求名称相同的视图
        return new ModelAndView("login/login");
    }
}
